package com.yay.mashiro.yayclient.ui.clickgui.controls;

import java.awt.Color;

import com.yay.mashiro.yayclient.Yay;
import com.yay.mashiro.yayclient.module.modules.render.ClickGui;
import com.yay.mashiro.yayclient.utils.Colors;
import com.yay.mashiro.yayclient.utils.PlayerUtils;

import ClassSub.Class246;

public class Switch {
	public String parent;
    public float x;
    public float y;
    public boolean state;
    double aniState;
    
    public Switch(String string) {
        this.parent = string;
        this.state = Yay.getModuleManager().getModuleByName(string).isEnabled();
        this.aniState = 8.0;
    }

    public Switch(String string, boolean bl) {
        this.parent = string;
        this.state = bl;
        this.aniState = 8.0;
    }

    public void draw(float f, float f2) {
        this.x = f;
        this.y = f2;
        this.aniState = Class246.getAnimationState(this.aniState, 8.0, 100.0);
        Class246.drawRoundedRect(f - 8.0f, f2 - 3.0f, f + 8.0f, f2 + 3.0f, 2.0f, ClickGui.theme.isCurrentMode("Light") ? new Color(Colors.GREY.c).brighter().getRGB() : new Color(40, 40, 40).getRGB());
        if (ClickGui.theme.isCurrentMode("Light")) {
            Class246.circle(this.state ? (float)((double)(f - 4.0f) + this.aniState) : (float)((double)(f + 4.0f) - this.aniState), f2, 4.0f, this.state ? new Color(-14848033).brighter().getRGB() : new Color(Colors.WHITE.c).darker().getRGB());
        } else {
            Class246.circle(this.state ? (float)((double)(f - 4.0f) + this.aniState) : (float)((double)(f + 4.0f) - this.aniState), f2, 4.0f, this.state ? -14848033 : -12369085);
        }
    }

    public void toggle() {
        this.state = !state;
        this.aniState = 0.0;
    }

    public void isPressed(int n, int n2, int mouseButton) {
        if (this.isHovering(n, n2, this.x - 12.0f, this.y - 5.0f, this.x + 12.0f, this.y + 5.0f)) {
            this.onPress(mouseButton);
        }
    }

    private boolean isHovering(int n, int n2, double d, double d2, double d3, double d4) {
        return ((double)n > d && (double)n < d3 && (double)n2 > d2 && (double)n2 < d4 ? 1 : 0) != 0;
    }

    public void onPress(int mouseButton) {
    	if(mouseButton == 0) {
        	this.toggle();
    	}
    }
}
